#!/usr/bin/env python

import sys
from IaaSSql import *

if __name__ == "__main__":
    argc = len(sys.argv)
    if argc < 2:
        sys.exit(0)
    else:
        conn = connectDB("localhost", "cloud", "cloudpass", "crane")
        cursor = cursorDB(conn)
        row = selectone(cursor, "select running_vms from image_pool where source = '" + sys.argv[1] +"';")
        if row:
            count = int(row[0])
            count += 1
            ret = update(cursor, "update image_pool set running_vms = " + str(count) + " where source = '" + sys.argv[1] + "';")
        closeDB(cursor)
        closeDB(conn)
